home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / EMSIF230.ARJ / EMSTEST2.C < prev    next >
C/C++ Source or Header  |  1991-12-01  |  42KB  |  1,063 lines

  1. /***************************************************************************
  2. *   emstest2.c                                                             *
  3. *   MODULE:  EMSIF                                                         *
  4. *   OS:      DOS                                                           *
  5. *   VERSION: 1.2                                                           *
  6. *   DATE:    12/01/91                                                      *
  7. *                                                                          *
  8. *   Copyright (c) 1991 James W. Birdsall. All Rights Reserved.             *
  9. *                                                                          *
  10. *   Requires emsif.h, testutil.h, and emstest.h to compile.                *
  11. *   Compiles under Borland C++ 2.0, TC 2.0, or MSC 6.0A.                   *
  12. *                                                                          *
  13. *   Regression test and example for EMSIF. See EMSTEST.C for more detail.  *
  14. *                                                                          *
  15. ***************************************************************************/
  16.  
  17. /*
  18. ** system includes <>
  19. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24.  
  25.  
  26. /*
  27. ** custom includes ""
  28. */
  29.  
  30. #include "testutil.h"
  31.  
  32. #include "emsif.h"
  33. #include "emstest.h"
  34.  
  35.  
  36. /*
  37. ** local #defines
  38. */
  39.  
  40. #define UCF                      unsigned char far
  41.  
  42. /*
  43. ** Checks to see if a region of memory is still incrementing word values,
  44. ** handles cleanup and exit if not.
  45. */
  46. #define WORDCHECK(buf, len, msg)                                \
  47.     if (farincwordcheck((UCF *) (buf), (len), 0) != 0) {        \
  48.         printf("Copy corrupted %s.\n", (msg)); EMMfree(handle); \
  49.         free(testbuf); exit(3); }
  50.  
  51. /*
  52. ** Check source and destination buffers, respectively.
  53. */
  54. #define SRCWORDCHECK(buf, len)    WORDCHECK(buf, len, "source buffer")
  55. #define CPYWORDCHECK(buf, len)    WORDCHECK(buf, len, "copied bytes")
  56.  
  57. /*
  58. ** Checks to see if a region of memory is still filled with a given value,
  59. ** handles cleanup and exit if not.
  60. */
  61. #define MEMCHECK(buf, len, val)                          \
  62.     if (farmemcheck((UCF *) (buf), (len), (val)) != 0) { \
  63.         printf("Copy corrupted destination.\n");         \
  64.         EMMfree(handle); free(testbuf); exit(3); }
  65.  
  66. /*
  67. ** Checks buffer for nonzero values.
  68. */
  69. #define ZEROCHECK(buf, len)       MEMCHECK(buf, len, '\0')
  70.  
  71. /*
  72. ** Compares two regions of memory, handles cleanup and exit if not the same.
  73. */
  74. #define MEMCMP(buf1, buf2, len)                                          \
  75.     if (FMEMCMP((void far *) (buf1), (void far *) (buf2), (len)) != 0) { \
  76.         printf("Copy corrupted copied bytes.\n"); EMMfree(handle);       \
  77.         free(testbuf); exit(3); }
  78.  
  79.  
  80. /*
  81. ** misc: copyright strings, version macros, etc.
  82. */
  83.  
  84. /*
  85. ** typedefs
  86. */
  87.  
  88. /*
  89. ** global variables
  90. */
  91.  
  92. /* see EMSTEST.C for info */
  93. extern int testno;
  94. extern unsigned char far *frameptr[];
  95. extern char *gblmsg;
  96.  
  97.  
  98. /*
  99. ** static globals
  100. */
  101.  
  102. /*
  103. ** function prototypes
  104. */
  105.  
  106. static void do_nshortcopy_tests(void);
  107. static void do_ishortcopy_tests(void);
  108.  
  109.  
  110. /*
  111. ** functions
  112. */
  113.  
  114.  
  115. /***************************************************************************
  116. *   FUNCTION: DO_SHORTCOPY_TESTS                                           *
  117. *                                                                          *
  118. *   DESCRIPTION:                                                           *
  119. *                                                                          *
  120. *       Central dispatching function for short copy tests.                 *
  121. *                                                                          *
  122. *   ENTRY:                                                                 *
  123. *                                                                          *
  124. *       Void.                                                              *
  125. *                                                                          *
  126. *   EXIT:                                                                  *
  127. *                                                                          *
  128. *       Void.                                                              *
  129. *                                                                          *
  130. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  131. *                                                                          *
  132. ***************************************************************************/
  133. void do_shortcopy_tests(void)
  134. {
  135.     do_nshortcopy_tests();
  136.     do_ishortcopy_tests();
  137.     return;
  138. } /* end of do_shortcopy_tests() */
  139.  
  140.  
  141. /***************************************************************************
  142. *   FUNCTION: DO_NSHORTCOPY_TESTS  (STATIC)                                *
  143. *                                                                          *
  144. *   DESCRIPTION:                                                           *
  145. *                                                                          *
  146. *       Tests EMSIF functions EMMcopyto() and EMMcopyfrom() with copies    *
  147. *       shorter than one EMS page ( <= 16384 bytes ).                      *
  148. *                                                                          *
  149. *   ENTRY:                                                                 *
  150. *                                                                          *
  151. *       Void.                                                              *
  152. *                                                                          *
  153. *   EXIT:                                                                  *
  154. *                                                                          *
  155. *       Void.                                                              *
  156. *                                                                          *
  157. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  158. *                                                                          *
  159. ***************************************************************************/
  160. static void do_nshortcopy_tests(void)
  161. {
  162.     unsigned char *testbuf;
  163.     int handle;
  164.     int status;
  165.     unsigned long ticks, totticks;
  166.     int loop;
  167.  
  168.     /* allocate memory to test against */
  169.     testbuf = (unsigned char *) malloc(16384);
  170.     if (testbuf == (unsigned char *) NULL)
  171.     {
  172.         printf("Cannot allocate test memory. Aborting.\n");
  173.         exit(1);
  174.     }
  175.  
  176.     /* now allocate a page of EMS to test with */
  177.     handle = test_EMMallocpages(1);
  178.  
  179.     /* fill test buffer with incrementing word pattern */
  180.     farincwordfill((UCF *) testbuf, 16384, 0);
  181.  
  182.     /* fill EMS page with a different pattern */
  183.     test_EMMmappage(0, handle, 0);
  184.     FMEMSET(frameptr[0], 0, 16384);
  185.  
  186.     /* try a bad copy first */
  187.     TESTHEADER();
  188.     printf("Calling EMMcopyto() with bad offset.\n");
  189.     printf("Should fail.\n");
  190.     status = EMMcopyto(5L, (UCF *) testbuf, handle, 20000L);
  191.     nofailcheck("EMMcopyto()", status, testbuf, handle, 0);
  192.     weirdretchk("EMMcopyto()", status, testbuf, handle, 0);
  193.     weirdcodechk("EMMcopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  194.     SRCWORDCHECK(testbuf, 16384);
  195.     test_EMMmappage(0, handle, 0);
  196.     ZEROCHECK(frameptr[0], 16384);
  197.     printf("EMMcopyto() failed OK.\n");
  198.     TESTTAILER();
  199.  
  200.     /* and another */
  201.     TESTHEADER();
  202.     printf("Calling EMMcopyto() with block that runs off end of EMS.\n");
  203.     printf("Should fail.\n");
  204.     status = EMMcopyto(500L, (UCF *) testbuf, handle, 16000L);
  205.     nofailcheck("EMMcopyto()", status, testbuf, handle, 0);
  206.     weirdretchk("EMMcopyto()", status, testbuf, handle, 0);
  207.     weirdcodechk("EMMcopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  208.     SRCWORDCHECK(testbuf, 16384);
  209.     test_EMMmappage(0, handle, 0);
  210.     ZEROCHECK(frameptr[0], 16384);
  211.     printf("EMMcopyto() failed OK.\n");
  212.     TESTTAILER();
  213.  
  214.     /* test zero-length copy */
  215.     TESTHEADER();
  216.     printf("Calling EMMcopyto() with zero-length source block.\n");
  217.     printf("Should succeed.\n");
  218.     status = EMMcopyto(0L, (UCF *) testbuf, handle, 0L);
  219.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  220.     SRCWORDCHECK(testbuf, 16384);
  221.     test_EMMmappage(0, handle, 0);
  222.     ZEROCHECK(frameptr[0], 16384);
  223.     printf("EMMcopyto() succeeded.\n");
  224.     TESTTAILER();
  225.  
  226.     /* test copy of even number of bytes to 0 offset */
  227.     TESTHEADER();
  228.     printf("Calling EMMcopyto() to copy 50 bytes to offset 0.\n");
  229.     status = EMMcopyto(50L, (UCF *) testbuf, handle, 0L);
  230.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  231.     SRCWORDCHECK(testbuf, 16384);
  232.     test_EMMmappage(0, handle, 0);
  233.     CPYWORDCHECK(frameptr[0], 50);
  234.     ZEROCHECK((frameptr[0] + 50), 16384 - 50);
  235.     printf("EMMcopyto() succeeded.\n");
  236.     TESTTAILER();
  237.  
  238.     /* restore EMS pattern */
  239.     test_EMMmappage(0, handle, 0);
  240.     FMEMSET(frameptr[0], 0, 16384);
  241.  
  242.     /* test copy of even number of bytes to even offset */
  243.     TESTHEADER();
  244.     printf("Calling EMMcopyto() to copy 50 bytes to even offset.\n");
  245.     status = EMMcopyto(50L, (UCF *) testbuf, handle, 498L);
  246.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  247.     SRCWORDCHECK(testbuf, 16384);
  248.     test_EMMmappage(0, handle, 0);
  249.     CPYWORDCHECK((frameptr[0] + 498), 50);
  250.     ZEROCHECK(frameptr[0], 498);
  251.     ZEROCHECK((frameptr[0] + 498 + 50), ((16384 - 498) - 50));
  252.     printf("EMMcopyto() succeeded.\n");
  253.     TESTTAILER();
  254.  
  255.     /* restore EMS pattern */
  256.     test_EMMmappage(0, handle, 0);
  257.     FMEMSET(frameptr[0], 0, 16384);
  258.  
  259.     /* test copy of even number of bytes to odd offset */
  260.     TESTHEADER();
  261.     printf("Calling EMMcopyto() to copy 50 bytes to odd offset.\n");
  262.     status = EMMcopyto(50L, (UCF *) testbuf, handle, 777L);
  263.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  264.     SRCWORDCHECK(testbuf, 16384);
  265.     test_EMMmappage(0, handle, 0);
  266.     CPYWORDCHECK((frameptr[0] + 777), 50);
  267.     ZEROCHECK(frameptr[0], 777);
  268.     ZEROCHECK((frameptr[0] + 777 + 50), ((16384 - 777) - 50));
  269.     printf("EMMcopyto() succeeded.\n");
  270.     TESTTAILER();
  271.  
  272.     /* restore EMS pattern */
  273.     test_EMMmappage(0, handle, 0);
  274.     FMEMSET(frameptr[0], 0, 16384);
  275.  
  276.     /* test copy of even number of bytes to offset just before end */
  277.     TESTHEADER();
  278.     printf(
  279.          "Calling EMMcopyto() to copy 50 bytes to just before end of page.\n");
  280.     status = EMMcopyto(50L, (UCF *) testbuf, handle, (16384L - 50L));
  281.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  282.     SRCWORDCHECK(testbuf, 16384);
  283.     test_EMMmappage(0, handle, 0);
  284.     CPYWORDCHECK((frameptr[0] + (16384 - 50)), 50);
  285.     ZEROCHECK(frameptr[0], (16384 - 50));
  286.     printf("EMMcopyto() succeeded.\n");
  287.     TESTTAILER();
  288.  
  289.     /* restore EMS pattern */
  290.     test_EMMmappage(0, handle, 0);
  291.     FMEMSET(frameptr[0], 0, 16384);
  292.  
  293.     /* test copy of odd number of bytes to 0 offset */
  294.     TESTHEADER();
  295.     printf("Calling EMMcopyto() to copy 77 bytes to offset 0.\n");
  296.     status = EMMcopyto(77L, (UCF *) testbuf, handle, 0L);
  297.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  298.     SRCWORDCHECK(testbuf, 16384);
  299.     test_EMMmappage(0, handle, 0);
  300.     MEMCMP(frameptr[0], testbuf, 77);
  301.     ZEROCHECK((frameptr[0] + 77), 16384 - 77);
  302.     printf("EMMcopyto() succeeded.\n");
  303.     TESTTAILER();
  304.  
  305.     /* restore EMS pattern */
  306.     test_EMMmappage(0, handle, 0);
  307.     FMEMSET(frameptr[0], 0, 16384);
  308.  
  309.     /* test copy of odd number of bytes to even offset */
  310.     TESTHEADER();
  311.     printf("Calling EMMcopyto() to copy 77 bytes to even offset.\n");
  312.     status = EMMcopyto(77L, (UCF *) testbuf, handle, 498L);
  313.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  314.     SRCWORDCHECK(testbuf, 16384);
  315.     test_EMMmappage(0, handle, 0);
  316.     MEMCMP((frameptr[0] + 498), testbuf, 77);
  317.     ZEROCHECK(frameptr[0], 498);
  318.     ZEROCHECK((frameptr[0] + 498 + 77), ((16384 - 498) - 77));
  319.     printf("EMMcopyto() succeeded.\n");
  320.     TESTTAILER();
  321.  
  322.     /* restore EMS pattern */
  323.     test_EMMmappage(0, handle, 0);
  324.     FMEMSET(frameptr[0], 0, 16384);
  325.  
  326.     /* test copy of odd number of bytes to odd offset */
  327.     TESTHEADER();
  328.     printf("Calling EMMcopyto() to copy 77 bytes to odd offset.\n");
  329.     status = EMMcopyto(77L, (UCF *) testbuf, handle, 777L);
  330.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  331.     SRCWORDCHECK(testbuf, 16384);
  332.     test_EMMmappage(0, handle, 0);
  333.     MEMCMP((frameptr[0] + 777), testbuf, 77);
  334.     ZEROCHECK(frameptr[0], 777);
  335.     ZEROCHECK((frameptr[0] + 777 + 77), ((16384 - 777) - 77));
  336.     printf("EMMcopyto() succeeded.\n");
  337.     TESTTAILER();
  338.  
  339.     /* restore EMS pattern */
  340.     test_EMMmappage(0, handle, 0);
  341.     FMEMSET(frameptr[0], 0, 16384);
  342.  
  343.     /* test copy of odd number of bytes to offset just before end */
  344.     TESTHEADER();
  345.     printf(
  346.          "Calling EMMcopyto() to copy 77 bytes to just before end of page.\n");
  347.     status = EMMcopyto(77L, (UCF *) testbuf, handle, (16384L - 77L));
  348.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  349.     SRCWORDCHECK(testbuf, 16384);
  350.     test_EMMmappage(0, handle, 0);
  351.     MEMCMP((frameptr[0] + (16384 - 77)), testbuf, 77);
  352.     ZEROCHECK(frameptr[0], (16384 - 77));
  353.     printf("EMMcopyto() succeeded.\n");
  354.     TESTTAILER();
  355.  
  356.     /* restore EMS pattern */
  357.     test_EMMmappage(0, handle, 0);
  358.     FMEMSET(frameptr[0], 0, 16384);
  359.  
  360.     /* copy entire page by words */
  361.     TESTHEADER();
  362.     printf("Calling EMMcopyto() to fill EMS page in chunks of 2 bytes.\n");
  363.     totticks = 0L;
  364.     for (loop = 0; loop < 16384; loop += 2)
  365.     {
  366.         ticks = get_tick();
  367.         status = EMMcopyto(2L, (UCF *) (testbuf + loop), handle,
  368.                                                          (unsigned long) loop);
  369.         totticks += (get_tick() - ticks);
  370.         TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  371.     }
  372.     SRCWORDCHECK(testbuf, 16384);
  373.     test_EMMmappage(0, handle, 0);
  374.     MEMCMP(frameptr[0], testbuf, 16384);
  375.     printf("EMMcopyto() succeeded, took about %lu ticks.\n", totticks);
  376.     TESTTAILER();
  377.  
  378.     /* restore EMS pattern */
  379.     test_EMMmappage(0, handle, 0);
  380.     FMEMSET(frameptr[0], 0, 16384);
  381.  
  382.     /* copy entire page at once */
  383.     TESTHEADER();
  384.     printf("Calling EMMcopyto() to copy entire page at once.\n");
  385.     ticks = get_tick();
  386.     status = EMMcopyto(16384L, (UCF *) testbuf, handle, 0L);
  387.     ticks = get_tick() - ticks;
  388.     TRIPLECHECK("EMMcopyto()", status, 0, testbuf, handle, 0);
  389.     SRCWORDCHECK(testbuf, 16384);
  390.     test_EMMmappage(0, handle, 0);
  391.     MEMCMP(frameptr[0], testbuf, 16384);
  392.     printf("EMMcopyto() succeeded, took about %lu ticks.\n", ticks);
  393.     TESTTAILER();
  394.  
  395.  
  396.     /* fill EMS page with incrementing word pattern */
  397.     test_EMMmappage(0, handle, 0);
  398.     farincwordfill(frameptr[0], 16384, 0);
  399.  
  400.     /* fill test buffer with a different pattern */
  401.     FMEMSET((UCF *) testbuf, 0, 16384);
  402.  
  403.     /* try a bad copy first */
  404.     TESTHEADER();
  405.     printf("Calling EMMcopyfrom() with bad offset.\n");
  406.     printf("Should fail.\n");
  407.     status = EMMcopyfrom(5L, handle, 20000L, (UCF *) testbuf);
  408.     nofailcheck("EMMcopyfrom()", status, testbuf, handle, 0);
  409.     weirdretchk("EMMcopyfrom()", status, testbuf, handle, 0);
  410.     weirdcodechk("EMMcopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  411.     test_EMMmappage(0, handle, 0);
  412.     SRCWORDCHECK(frameptr[0], 16384);
  413.     ZEROCHECK(testbuf, 16384);
  414.     printf("EMMcopyfrom() failed OK.\n");
  415.     TESTTAILER();
  416.  
  417.     /* and another */
  418.     TESTHEADER();
  419.     printf("Calling EMMcopyfrom() with block that runs off end of EMS.\n");
  420.     printf("Should fail.\n");
  421.     status = EMMcopyfrom(500L, handle, 16000L, (UCF *) testbuf);
  422.     nofailcheck("EMMcopyfrom()", status, testbuf, handle, 0);
  423.     weirdretchk("EMMcopyfrom()", status, testbuf, handle, 0);
  424.     weirdcodechk("EMMcopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  425.     test_EMMmappage(0, handle, 0);
  426.     SRCWORDCHECK(frameptr[0], 16384);
  427.     ZEROCHECK(testbuf, 16384);
  428.     printf("EMMcopyfrom() failed OK.\n");
  429.     TESTTAILER();
  430.  
  431.     /* test zero-length copy */
  432.     TESTHEADER();
  433.     printf("Calling EMMcopyfrom() with zero-length source block.\n");
  434.     printf("Should succeed.\n");
  435.     status = EMMcopyfrom(0L, handle, 0L, (UCF *) testbuf);
  436.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  437.     test_EMMmappage(0, handle, 0);
  438.     SRCWORDCHECK(frameptr[0], 16384);
  439.     ZEROCHECK(testbuf, 16384);
  440.     printf("EMMcopyfrom() succeeded.\n");
  441.     TESTTAILER();
  442.  
  443.     /* test copy of even number of bytes to 0 offset */
  444.     TESTHEADER();
  445.     printf("Calling EMMcopyfrom() to copy 50 bytes to offset 0.\n");
  446.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) testbuf);
  447.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  448.     test_EMMmappage(0, handle, 0);
  449.     SRCWORDCHECK(frameptr[0], 16384);
  450.     CPYWORDCHECK(testbuf, 50);
  451.     ZEROCHECK((testbuf + 50), 16384 - 50);
  452.     printf("EMMcopyfrom() succeeded.\n");
  453.     TESTTAILER();
  454.  
  455.     /* restore destination pattern */
  456.     FMEMSET((UCF *) testbuf, 0, 16384);
  457.  
  458.     /* test copy of even number of bytes to even offset */
  459.     TESTHEADER();
  460.     printf("Calling EMMcopyfrom() to copy 50 bytes to even offset.\n");
  461.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) (testbuf + 498));
  462.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  463.     test_EMMmappage(0, handle, 0);
  464.     SRCWORDCHECK(frameptr[0], 16384);
  465.     CPYWORDCHECK((testbuf + 498), 50);
  466.     ZEROCHECK(testbuf, 498);
  467.     ZEROCHECK((testbuf + 498 + 50), ((16384 - 498) - 50));
  468.     printf("EMMcopyfrom() succeeded.\n");
  469.     TESTTAILER();
  470.  
  471.     /* restore destination pattern */
  472.     FMEMSET((UCF *) testbuf, 0, 16384);
  473.  
  474.     /* test copy of even number of bytes to odd offset */
  475.     TESTHEADER();
  476.     printf("Calling EMMcopyfrom() to copy 50 bytes to odd offset.\n");
  477.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) (testbuf + 777));
  478.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  479.     test_EMMmappage(0, handle, 0);
  480.     SRCWORDCHECK(frameptr[0], 16384);
  481.     CPYWORDCHECK((testbuf + 777), 50);
  482.     ZEROCHECK(testbuf, 777);
  483.     ZEROCHECK((testbuf + 777 + 50), ((16384 - 777) - 50));
  484.     printf("EMMcopyfrom() succeeded.\n");
  485.     TESTTAILER();
  486.  
  487.     /* restore destination pattern */
  488.     FMEMSET((UCF *) testbuf, 0, 16384);
  489.  
  490.     /* test copy of even number of bytes to offset just before end */
  491.     TESTHEADER();
  492.     printf(
  493.          "Calling EMMcopyfrom() to copy 50 bytes to just before end of page.\n");
  494.     status = EMMcopyfrom(50L, handle, 0L, (UCF *) (testbuf + (16384 - 50)));
  495.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  496.     test_EMMmappage(0, handle, 0);
  497.     SRCWORDCHECK(frameptr[0], 16384);
  498.     CPYWORDCHECK((testbuf + (16384 - 50)), 50);
  499.     ZEROCHECK(testbuf, (16384 - 50));
  500.     printf("EMMcopyfrom() succeeded.\n");
  501.     TESTTAILER();
  502.  
  503.     /* restore destination pattern */
  504.     FMEMSET((UCF *) testbuf, 0, 16384);
  505.  
  506.     /* test copy of odd number of bytes to 0 offset */
  507.     TESTHEADER();
  508.     printf("Calling EMMcopyfrom() to copy 77 bytes to offset 0.\n");
  509.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) testbuf);
  510.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  511.     test_EMMmappage(0, handle, 0);
  512.     SRCWORDCHECK(frameptr[0], 16384);
  513.     MEMCMP(testbuf, frameptr[0], 77);
  514.     ZEROCHECK((testbuf + 77), 16384 - 77);
  515.     printf("EMMcopyfrom() succeeded.\n");
  516.     TESTTAILER();
  517.  
  518.     /* restore destination pattern */
  519.     FMEMSET((UCF *) testbuf, 0, 16384);
  520.  
  521.     /* test copy of odd number of bytes to even offset */
  522.     TESTHEADER();
  523.     printf("Calling EMMcopyfrom() to copy 77 bytes to even offset.\n");
  524.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) (testbuf + 498));
  525.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  526.     test_EMMmappage(0, handle, 0);
  527.     SRCWORDCHECK(frameptr[0], 16384);
  528.     MEMCMP((testbuf + 498), frameptr[0], 77);
  529.     ZEROCHECK(testbuf, 498);
  530.     ZEROCHECK((testbuf + 498 + 77), ((16384 - 498) - 77));
  531.     printf("EMMcopyfrom() succeeded.\n");
  532.     TESTTAILER();
  533.  
  534.     /* restore destination pattern */
  535.     FMEMSET((UCF *) testbuf, 0, 16384);
  536.  
  537.     /* test copy of odd number of bytes to odd offset */
  538.     TESTHEADER();
  539.     printf("Calling EMMcopyfrom() to copy 77 bytes to odd offset.\n");
  540.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) (testbuf + 777));
  541.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  542.     test_EMMmappage(0, handle, 0);
  543.     SRCWORDCHECK(frameptr[0], 16384);
  544.     MEMCMP((testbuf + 777), frameptr[0], 77);
  545.     ZEROCHECK(testbuf, 777);
  546.     ZEROCHECK((testbuf + 777 + 77), ((16384 - 777) - 77));
  547.     printf("EMMcopyfrom() succeeded.\n");
  548.     TESTTAILER();
  549.  
  550.     /* restore destination pattern */
  551.     FMEMSET((UCF *) testbuf, 0, 16384);
  552.  
  553.     /* test copy of odd number of bytes to offset just before end */
  554.     TESTHEADER();
  555.     printf(
  556.        "Calling EMMcopyfrom() to copy 77 bytes to just before end of page.\n");
  557.     status = EMMcopyfrom(77L, handle, 0L, (UCF *) (testbuf + (16384 - 77)));
  558.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  559.     test_EMMmappage(0, handle, 0);
  560.     SRCWORDCHECK(frameptr[0], 16384);
  561.     MEMCMP((testbuf + (16384 - 77)), frameptr[0], 77);
  562.     ZEROCHECK(testbuf, (16384 - 77));
  563.     printf("EMMcopyfrom() succeeded.\n");
  564.     TESTTAILER();
  565.  
  566.     /* restore destination pattern */
  567.     FMEMSET((UCF *) testbuf, 0, 16384);
  568.  
  569.     /* copy entire page by words */
  570.     TESTHEADER();
  571.     printf("Calling EMMcopyfrom() to fill buffer in chunks of 2 bytes.\n");
  572.     totticks = 0L;
  573.     for (loop = 0; loop < 16384; loop += 2)
  574.     {
  575.         ticks = get_tick();
  576.         status = EMMcopyfrom(2L, handle, (unsigned long) loop,
  577.                                                      (UCF *) (testbuf + loop));
  578.         totticks += (get_tick() - ticks);
  579.         TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  580.     }
  581.     test_EMMmappage(0, handle, 0);
  582.     SRCWORDCHECK(frameptr[0], 16384);
  583.     MEMCMP(testbuf, frameptr[0], 16384);
  584.     printf("EMMcopyfrom() succeeded, took about %lu ticks.\n", totticks);
  585.     TESTTAILER();
  586.  
  587.     /* restore destination pattern */
  588.     FMEMSET((UCF *) testbuf, 0, 16384);
  589.  
  590.     /* copy entire page at once */
  591.     TESTHEADER();
  592.     printf("Calling EMMcopyfrom() to copy entire page at once.\n");
  593.     ticks = get_tick();
  594.     status = EMMcopyfrom(16384L, handle, 0L, (UCF *) testbuf);
  595.     ticks = get_tick() - ticks;
  596.     TRIPLECHECK("EMMcopyfrom()", status, 0, testbuf, handle, 0);
  597.     test_EMMmappage(0, handle, 0);
  598.     SRCWORDCHECK(frameptr[0], 16384);
  599.     MEMCMP(testbuf, frameptr[0], 16384);
  600.     printf("EMMcopyfrom() succeeded, took about %lu ticks.\n", ticks);
  601.     TESTTAILER();
  602.  
  603.     /* clean up */
  604.     test_EMMfree(handle);
  605.     free(testbuf);
  606.  
  607.     return;
  608. } /* end of do_nshortcopy_tests() */
  609.  
  610.  
  611. /***************************************************************************
  612. *   FUNCTION: DO_ISHORTCOPY_TESTS  (STATIC)                                *
  613. *                                                                          *
  614. *   DESCRIPTION:                                                           *
  615. *                                                                          *
  616. *       Tests EMSIF functions _EMMicopyto() and _EMMicopyfrom() with       *
  617. *       copies shorter than one EMS page ( <= 16384 bytes ).               *
  618. *                                                                          *
  619. *   ENTRY:                                                                 *
  620. *                                                                          *
  621. *       Void.                                                              *
  622. *                                                                          *
  623. *   EXIT:                                                                  *
  624. *                                                                          *
  625. *       Void.                                                              *
  626. *                                                                          *
  627. *   CONSTRAINTS/SIDE EFFECTS:                                              *
  628. *                                                                          *
  629. ***************************************************************************/
  630. static void do_ishortcopy_tests(void)
  631. {
  632.     unsigned char *testbuf;
  633.     int handle;
  634.     int status;
  635.     unsigned long ticks, totticks;
  636.     int loop;
  637.  
  638.     /* allocate memory to test against */
  639.     testbuf = (unsigned char *) malloc(16384);
  640.     if (testbuf == (unsigned char *) NULL)
  641.     {
  642.         printf("Cannot allocate test memory. Aborting.\n");
  643.         exit(1);
  644.     }
  645.  
  646.     /* now allocate a page of EMS to test with */
  647.     handle = test_EMMallocpages(1);
  648.  
  649.     /* fill test buffer with incrementing word pattern */
  650.     farincwordfill((UCF *) testbuf, 16384, 0);
  651.  
  652.     /* fill EMS page with a different pattern */
  653.     test_EMMmappage(0, handle, 0);
  654.     FMEMSET(frameptr[0], 0, 16384);
  655.  
  656.     /* try a bad copy first */
  657.     TESTHEADER();
  658.     printf("Calling _EMMicopyto() with bad offset.\n");
  659.     printf("Should fail.\n");
  660.     status = EMMicopyto(5L, 2, 2, (UCF *) testbuf, handle, 20000L);
  661.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  662.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  663.     weirdcodechk("_EMMicopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  664.     SRCWORDCHECK(testbuf, 16384);
  665.     test_EMMmappage(0, handle, 0);
  666.     ZEROCHECK(frameptr[0], 16384);
  667.     printf("_EMMicopyto() failed OK.\n");
  668.     TESTTAILER();
  669.  
  670.     /* and another */
  671.     TESTHEADER();
  672.     printf("Calling _EMMicopyto() with block that runs off end of EMS.\n");
  673.     printf("Should fail.\n");
  674.     status = EMMicopyto(500L, 2, 2, (UCF *) testbuf, handle, 16000L);
  675.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  676.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  677.     weirdcodechk("_EMMicopyto()", EMM_BADOFFSET, testbuf, handle, 0);
  678.     SRCWORDCHECK(testbuf, 16384);
  679.     test_EMMmappage(0, handle, 0);
  680.     ZEROCHECK(frameptr[0], 16384);
  681.     printf("_EMMicopyto() failed OK.\n");
  682.     TESTTAILER();
  683.  
  684.     /* and another */
  685.     TESTHEADER();
  686.     printf("Calling _EMMicopyto() with element size > 16384 bytes.\n");
  687.     printf("Should fail.\n");
  688.     status = EMMicopyto(2L, 20000, 2, (UCF *) testbuf, handle, 0L);
  689.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  690.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  691.     weirdcodechk("_EMMicopyto()", EMM_ELTOOBIG, testbuf, handle, 0);
  692.     SRCWORDCHECK(testbuf, 16384);
  693.     test_EMMmappage(0, handle, 0);
  694.     ZEROCHECK(frameptr[0], 16384);
  695.     printf("_EMMicopyto() failed OK.\n");
  696.     TESTTAILER();
  697.  
  698.     /* and another */
  699.     TESTHEADER();
  700.     printf("Calling _EMMicopyto() with skip size > 32768 bytes.\n");
  701.     printf("Should fail.\n");
  702.     status = EMMicopyto(2L, 2, 40000U, (UCF *) testbuf, handle, 0L);
  703.     nofailcheck("_EMMicopyto()", status, testbuf, handle, 0);
  704.     weirdretchk("_EMMicopyto()", status, testbuf, handle, 0);
  705.     weirdcodechk("_EMMicopyto()", EMM_SKTOOBIG, testbuf, handle, 0);
  706.     SRCWORDCHECK(testbuf, 16384);
  707.     test_EMMmappage(0, handle, 0);
  708.     ZEROCHECK(frameptr[0], 16384);
  709.     printf("_EMMicopyto() failed OK.\n");
  710.     TESTTAILER();
  711.  
  712.     /* test zero-length copy */
  713.     TESTHEADER();
  714.     printf("Calling _EMMicopyto() with zero elements.\n");
  715.     printf("Should succeed.\n");
  716.     status = EMMicopyto(0L, 2, 2, (UCF *) testbuf, handle, 0L);
  717.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  718.     SRCWORDCHECK(testbuf, 16384);
  719.     test_EMMmappage(0, handle, 0);
  720.     ZEROCHECK(frameptr[0], 16384);
  721.     printf("_EMMicopyto() succeeded.\n");
  722.     TESTTAILER();
  723.  
  724.     /* test zero-length copy differently */
  725.     TESTHEADER();
  726.     printf("Calling _EMMicopyto() with zero-length elements.\n");
  727.     printf("Should succeed.\n");
  728.     status = EMMicopyto(50L, 0, 2, (UCF *) testbuf, handle, 0L);
  729.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  730.     SRCWORDCHECK(testbuf, 16384);
  731.     test_EMMmappage(0, handle, 0);
  732.     ZEROCHECK(frameptr[0], 16384);
  733.     printf("_EMMicopyto() succeeded.\n");
  734.     TESTTAILER();
  735.  
  736.     /* test skip size of 0 */
  737.     TESTHEADER();
  738.     printf("Calling _EMMicopyto() with zero source and dest skip.\n");
  739.     printf("Should succeed.\n");
  740.     status = EMMicopyto(50L, 2, 0, (UCF *) testbuf, handle, 0L);
  741.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  742.     SRCWORDCHECK(testbuf, 16384);
  743.     test_EMMmappage(0, handle, 0);
  744.     CPYWORDCHECK(frameptr[0], 100);
  745.     ZEROCHECK((frameptr[0] + 100), (16384 - 100));
  746.     printf("_EMMicopyto() succeeded.\n");
  747.     TESTTAILER();
  748.  
  749.     /* restore destination pattern */
  750.     test_EMMmappage(0, handle, 0);
  751.     FMEMSET(frameptr[0], 0, 16384);
  752.  
  753.     /* test copy even same skip, even size */
  754.     TESTHEADER();
  755.     printf("Calling _EMMicopyto() size, skips even,.\n");
  756.     printf("Should succeed.\n");
  757.     status = EMMicopyto(25L, 2, 4, (UCF *) testbuf, handle, 0L);
  758.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  759.     status = EMMicopyto(25L, 4, 2, (UCF *) (testbuf + 2), handle, 2L);
  760.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  761.     SRCWORDCHECK(testbuf, 16384);
  762.     test_EMMmappage(0, handle, 0);
  763.     CPYWORDCHECK(frameptr[0], 150);
  764.     ZEROCHECK((frameptr[0] + 150), (16384 - 150));
  765.     printf("_EMMicopyto() succeeded.\n");
  766.     TESTTAILER();
  767.  
  768.     /* restore destination pattern */
  769.     test_EMMmappage(0, handle, 0);
  770.     FMEMSET(frameptr[0], 0, 16384);
  771.  
  772.     /* test copy of size even, skip same odd and size odd, skip same even */
  773.     printf("Calling _EMMicopyto() with size even/skips odd & size odd/skips ");
  774.     printf("even.\nShould succeed.\n");
  775.     status = EMMicopyto(25L, 2, 3, (UCF *) testbuf, handle, 0L);
  776.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  777.     status = EMMicopyto(25L, 3, 2, (UCF *) (testbuf + 2), handle, 2L);
  778.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  779.     SRCWORDCHECK(testbuf, 16384);
  780.     test_EMMmappage(0, handle, 0);
  781.     MEMCMP(frameptr[0], testbuf, 125);
  782.     ZEROCHECK((frameptr[0] + 125), (16384 - 125));
  783.     printf("_EMMicopyto() succeeded.\n");
  784.     TESTTAILER();
  785.  
  786.     /* restore destination pattern */
  787.     test_EMMmappage(0, handle, 0);
  788.     FMEMSET(frameptr[0], 0, 16384);
  789.  
  790.     /* test copy of skip same odd, size odd */
  791.     TESTHEADER();
  792.     printf("Calling _EMMicopyto() with skips and size odd.\n");
  793.     printf("Should succeed.\n");
  794.     status = EMMicopyto(25L, 3, 7, (UCF *) testbuf, handle, 0L);
  795.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  796.     status = EMMicopyto(25L, 7, 3, (UCF *) (testbuf + 3), handle, 3L);
  797.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  798.     SRCWORDCHECK(testbuf, 16384);
  799.     test_EMMmappage(0, handle, 0);
  800.     CPYWORDCHECK(frameptr[0], 250);
  801.     ZEROCHECK((frameptr[0] + 250), (16384 - 250));
  802.     printf("_EMMicopyto() succeeded.\n");
  803.     TESTTAILER();
  804.  
  805.     /* restore destination pattern */
  806.     test_EMMmappage(0, handle, 0);
  807.     FMEMSET(frameptr[0], 0, 16384);
  808.  
  809.     /* copy entire page in two passes */
  810.     TESTHEADER();
  811.     printf("Calling _EMMicopyto() to copy page in two passes, by words.\n");
  812.     totticks = 0L;
  813.     ticks = get_tick();
  814.     status = EMMicopyto(4096L, 2, 2, (UCF *) testbuf, handle, 0L);
  815.     totticks += (get_tick() - ticks);
  816.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  817.     ticks = get_tick();
  818.     status = EMMicopyto(4096L, 2, 2, (UCF *) (testbuf + 2), handle, 2L);
  819.     totticks += (get_tick() - ticks);
  820.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  821.     SRCWORDCHECK(testbuf, 16384);
  822.     test_EMMmappage(0, handle, 0);
  823.     MEMCMP(frameptr[0], testbuf, 16384);
  824.     printf("_EMMicopyto() succeeded, took about %lu ticks.\n", totticks);
  825.     TESTTAILER();
  826.  
  827.     /* restore destination pattern */
  828.     test_EMMmappage(0, handle, 0);
  829.     FMEMSET(frameptr[0], 0, 16384);
  830.  
  831.     /* copy entire page, interleaving */
  832.     TESTHEADER();
  833.     printf(
  834.        "Calling _EMMicopyto() to copy page in two passes, skips different.\n");
  835.     status = _EMMicopyto(4096L, 2, 2, (UCF *) testbuf, handle, 0L, 0);
  836.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  837.     status = _EMMicopyto(4096L, 2, 2, (UCF *) (testbuf + 2), handle, 8192L, 0);
  838.     TRIPLECHECK("_EMMicopyto()", status, 0, testbuf, handle, 0);
  839.     SRCWORDCHECK(testbuf, 16384);
  840.     test_EMMmappage(0, handle, 0);
  841.     for (loop = 0; loop < 8192; loop += 2)
  842.     {
  843.         if ((*((unsigned int far *)(frameptr[0] + loop)) != loop) ||
  844.             (*((unsigned int far *)(frameptr[0] + loop + 8192)) != (loop + 1)))
  845.         {
  846.             printf("_EMMicopyto() corrupted copied bytes.\n");
  847.             free(testbuf);
  848.             test_EMMfree(handle);
  849.             exit(3);
  850.         }
  851.     }
  852.     TESTTAILER();
  853.  
  854.  
  855.     /* fill EMS page with incrementing word pattern */
  856.     test_EMMmappage(0, handle, 0);
  857.     farincwordfill(frameptr[0], 16384, 0);
  858.  
  859.     /* fill test buffer with a different pattern */
  860.     FMEMSET((UCF *) testbuf, 0, 16384);
  861.  
  862.     /* try a bad copy first */
  863.     TESTHEADER();
  864.     printf("Calling _EMMicopyfrom() with bad offset.\n");
  865.     printf("Should fail.\n");
  866.     status = EMMicopyfrom(5L, 2, 2, handle, 20000L, (UCF *) testbuf);
  867.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  868.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  869.     weirdcodechk("_EMMicopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  870.     test_EMMmappage(0, handle, 0);
  871.     SRCWORDCHECK(frameptr[0], 16384);
  872.     ZEROCHECK(testbuf, 16384);
  873.     printf("_EMMicopyfrom() failed OK.\n");
  874.     TESTTAILER();
  875.  
  876.     /* and another */
  877.     TESTHEADER();
  878.     printf("Calling _EMMicopyfrom() with block that runs off end of EMS.\n");
  879.     printf("Should fail.\n");
  880.     status = EMMicopyfrom(500L, 2, 2, handle, 16000L, (UCF *) testbuf);
  881.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  882.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  883.     weirdcodechk("_EMMicopyfrom()", EMM_BADOFFSET, testbuf, handle, 0);
  884.     test_EMMmappage(0, handle, 0);
  885.     SRCWORDCHECK(frameptr[0], 16384);
  886.     ZEROCHECK(testbuf, 16384);
  887.     printf("_EMMicopyfrom() failed OK.\n");
  888.     TESTTAILER();
  889.  
  890.     /* and another */
  891.     TESTHEADER();
  892.     printf("Calling _EMMicopyfrom() with element size > 16384 bytes.\n");
  893.     printf("Should fail.\n");
  894.     status = EMMicopyfrom(2L, 20000, 2, handle, 0L, (UCF *) testbuf);
  895.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  896.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  897.     weirdcodechk("_EMMicopyfrom()", EMM_ELTOOBIG, testbuf, handle, 0);
  898.     test_EMMmappage(0, handle, 0);
  899.     SRCWORDCHECK(frameptr[0], 16384);
  900.     ZEROCHECK(testbuf, 16384);
  901.     printf("_EMMicopyfrom() failed OK.\n");
  902.     TESTTAILER();
  903.  
  904.     /* and another */
  905.     TESTHEADER();
  906.     printf("Calling _EMMicopyfrom() with skip size > 32768 bytes.\n");
  907.     printf("Should fail.\n");
  908.     status = EMMicopyfrom(2L, 2, 40000U, handle, 0L, (UCF *) testbuf);
  909.     nofailcheck("_EMMicopyfrom()", status, testbuf, handle, 0);
  910.     weirdretchk("_EMMicopyfrom()", status, testbuf, handle, 0);
  911.     weirdcodechk("_EMMicopyfrom()", EMM_SKTOOBIG, testbuf, handle, 0);
  912.     test_EMMmappage(0, handle, 0);
  913.     SRCWORDCHECK(frameptr[0], 16384);
  914.     ZEROCHECK(testbuf, 16384);
  915.     printf("_EMMicopyfrom() failed OK.\n");
  916.     TESTTAILER();
  917.  
  918.     /* test zero-length copy */
  919.     TESTHEADER();
  920.     printf("Calling _EMMicopyfrom() with zero elements.\n");
  921.     printf("Should succeed.\n");
  922.     status = EMMicopyfrom(0L, 2, 2, handle, 0L, (UCF *) testbuf);
  923.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  924.     test_EMMmappage(0, handle, 0);
  925.     SRCWORDCHECK(frameptr[0], 16384);
  926.     ZEROCHECK(testbuf, 16384);
  927.     printf("_EMMicopyfrom() succeeded.\n");
  928.     TESTTAILER();
  929.  
  930.     /* test zero-length copy differently */
  931.     TESTHEADER();
  932.     printf("Calling _EMMicopyfrom() with zero-length elements.\n");
  933.     printf("Should succeed.\n");
  934.     status = EMMicopyfrom(50L, 0, 2, handle, 0L, (UCF *) testbuf);
  935.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  936.     test_EMMmappage(0, handle, 0);
  937.     SRCWORDCHECK(frameptr[0], 16384);
  938.     ZEROCHECK(testbuf, 16384);
  939.     printf("_EMMicopyfrom() succeeded.\n");
  940.     TESTTAILER();
  941.  
  942.     /* test skip size of 0 */
  943.     TESTHEADER();
  944.     printf("Calling _EMMicopyfrom() with zero source and dest skip.\n");
  945.     printf("Should succeed.\n");
  946.     status = EMMicopyfrom(50L, 2, 0, handle, 0L, (UCF *) testbuf);
  947.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  948.     test_EMMmappage(0, handle, 0);
  949.     SRCWORDCHECK(frameptr[0], 16384);
  950.     CPYWORDCHECK(testbuf, 100);
  951.     ZEROCHECK((testbuf + 100), (16384 - 100));
  952.     printf("_EMMicopyfrom() succeeded.\n");
  953.     TESTTAILER();
  954.  
  955.     /* restore destination pattern */
  956.     FMEMSET((UCF *) testbuf, 0, 16384);
  957.  
  958.     /* test copy even same skip, even size */
  959.     TESTHEADER();
  960.     printf("Calling _EMMicopyfrom() with size, skips even.\n");
  961.     printf("Should succeed.\n");
  962.     status = EMMicopyfrom(25L, 2, 4, handle, 0L, (UCF *) testbuf);
  963.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  964.     status = EMMicopyfrom(25L, 4, 2, handle, 2L, (UCF *) (testbuf + 2));
  965.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  966.     test_EMMmappage(0, handle, 0);
  967.     SRCWORDCHECK(frameptr[0], 16384);
  968.     CPYWORDCHECK(testbuf, 150);
  969.     ZEROCHECK((testbuf + 150), (16384 - 150));
  970.     printf("_EMMicopyfrom() succeeded.\n");
  971.     TESTTAILER();
  972.  
  973.     /* restore destination pattern */
  974.     FMEMSET((UCF *) testbuf, 0, 16384);
  975.  
  976.     /* test copy of size even, skip same odd and size odd, skip same even */
  977.     printf("Calling _EMMicopyfrom() with size even/skips odd & size odd/");
  978.     printf("skips even, offset even.\nShould succeed.\n");
  979.     status = EMMicopyfrom(25L, 2, 3, handle, 0L, (UCF *) testbuf);
  980.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  981.     status = EMMicopyfrom(25L, 3, 2, handle, 2L, (UCF *) (testbuf + 2));
  982.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  983.     test_EMMmappage(0, handle, 0);
  984.     SRCWORDCHECK(frameptr[0], 16384);
  985.     MEMCMP(frameptr[0], testbuf, 125);
  986.     ZEROCHECK((testbuf + 125), (16384 - 125));
  987.     printf("_EMMicopyfrom() succeeded.\n");
  988.     TESTTAILER();
  989.  
  990.     /* restore destination pattern */
  991.     FMEMSET((UCF *) testbuf, 0, 16384);
  992.  
  993.     /* test copy of skip same odd, size odd */
  994.     TESTHEADER();
  995.     printf("Calling _EMMicopyfrom() with skips and size odd.\n");
  996.     printf("Should succeed.\n");
  997.     status = EMMicopyfrom(25L, 3, 7, handle, 0L, (UCF *) testbuf);
  998.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  999.     status = EMMicopyfrom(25L, 7, 3, handle, 3L, (UCF *) (testbuf + 3));
  1000.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1001.     test_EMMmappage(0, handle, 0);
  1002.     SRCWORDCHECK(frameptr[0], 16384);
  1003.     CPYWORDCHECK(testbuf, 250);
  1004.     ZEROCHECK((testbuf + 250), (16384 - 250));
  1005.     printf("_EMMicopyfrom() succeeded.\n");
  1006.     TESTTAILER();
  1007.  
  1008.     /* restore destination pattern */
  1009.     FMEMSET((UCF *) testbuf, 0, 16384);
  1010.  
  1011.     /* copy entire page in two passes */
  1012.     TESTHEADER();
  1013.     printf("Calling _EMMicopyfrom() to copy page in two passes, by words.\n");
  1014.     totticks = 0L;
  1015.     ticks = get_tick();
  1016.     status = EMMicopyfrom(4096L, 2, 2, handle, 0L, (UCF *) testbuf);
  1017.     totticks += (get_tick() - ticks);
  1018.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1019.     ticks = get_tick();
  1020.     status = EMMicopyfrom(4096L, 2, 2, handle, 2L, (UCF *) (testbuf + 2));
  1021.     totticks += (get_tick() - ticks);
  1022.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1023.     test_EMMmappage(0, handle, 0);
  1024.     SRCWORDCHECK(frameptr[0], 16384);
  1025.     MEMCMP(testbuf, frameptr[0], 16384);
  1026.     printf("_EMMicopyfrom() succeeded, took about %lu ticks.\n", totticks);
  1027.     TESTTAILER();
  1028.  
  1029.     /* restore destination pattern */
  1030.     FMEMSET((UCF *) testbuf, 0, 16384);
  1031.  
  1032.     /* copy entire page, interleaving */
  1033.     TESTHEADER();
  1034.     printf(
  1035.        "Calling _EMMicopyfrom() to copy page in two passes, skips different.\n");
  1036.     status = _EMMicopyfrom(4096L, 2, 2, handle, 0L, (UCF *) testbuf, 0);
  1037.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1038.     status = _EMMicopyfrom(4096L, 2, 2, handle, 2L, (UCF *) (testbuf+8192), 0);
  1039.     TRIPLECHECK("_EMMicopyfrom()", status, 0, testbuf, handle, 0);
  1040.     test_EMMmappage(0, handle, 0);
  1041.     SRCWORDCHECK(frameptr[0], 16384);
  1042.     for (loop = 0; loop < 8192; loop += 2)
  1043.     {
  1044.         if ((*((unsigned int far *)(testbuf + loop)) != loop) ||
  1045.             (*((unsigned int far *)(testbuf + loop + 8192)) != (loop + 1)))
  1046.         {
  1047.             printf("_EMMicopyfrom() corrupted copied bytes.\n");
  1048.             free(testbuf);
  1049.             test_EMMfree(handle);
  1050.             exit(3);
  1051.         }
  1052.     }
  1053.     TESTTAILER();
  1054.  
  1055.  
  1056.     /* clean up */
  1057.     test_EMMfree(handle);
  1058.     free(testbuf);
  1059.  
  1060.     return;
  1061. } /* end of do_ishortcopy_tests() */
  1062.  
  1063.